package JD;


import java.math.BigInteger;
import java.util.Scanner;

public class Main1 {
    public static void main(String[] args) {
        Scanner cin=new Scanner(System.in);
        int N=cin.nextInt();
        Long X=cin.nextLong();
        BigInteger x=new  BigInteger(String.valueOf(X));
        cin.nextLine();
        char[] chars = cin.nextLine().toCharArray();
        for (char c:chars) {
            if (c == 'U') {
                x=x.divide(BigInteger.valueOf(2));
            }else if (c=='L'){
                x=x.multiply(BigInteger.valueOf(2));
            }else if (c=='R'){
                x=x.multiply(BigInteger.valueOf(2));
                x=x.add(BigInteger.valueOf(1));
            }
        }
        System.out.println(x.toString());
    }
}
